#!/usr/bin/env ruby -wKU
# encoding: utf-8

module Crawler
  
  require 'open-uri'
  require 'nokogiri'
  
  class HtmlParser
    
    URL = 'http://www.smzdm.com/'
    
    def self.crawl
      begin
        page = Nokogiri::HTML(open(URL))
      rescue => e
        puts "Error: #{e.class}, #{e.message}"
      end
      
      # find items
      page.css('div.perContentBox > h2 > a')
    end
    
  end
  
  if __FILE__ == $0
    data = HtmlParser.crawl
    data.each { |x|
      puts x['title']
      puts x['href']
    }
  end
  
end